<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<div id="time">

		</div>
		<script type="text/javascript">
			//3. 使用js做一个电子表, 显示当前时间，格式为: yyyy-mm-dd hh:mm:ss, 并能够随时间跳动，可以参考js时间对象。
			var timer = setInterval(function() {
				var time = new Date();
				var year = time.getFullYear(); //获取当前的年份
				var month = time.getMonth() + 1; //获取当前的月份
				var day = time.getDate(); //获取当前的日期
				var hours = time.getHours(); //获取当前的小时
				var minutes = time.getMinutes(); //获取当前的分钟
				var second = time.getSeconds(); //获取当前的秒数
				if (month < 10) {
					month = "0" + month;
				}
				if (day < 10) {
					day = "0" + day;
				}
				if (hours < 10) {
					hours = "0" + hours;
				}
				if (minutes < 10) {
					minutes = "0" + minutes;
				}
				if (second < 10) {
					second = "0" + second;
				}
				var n = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + second;
				document.getElementById("time").innerHTML = n;
			}, 1000); //这里1000就是换算
		</script>
	</body>
</html>
